{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
    <link rel="stylesheet" type="text/css" href="/css/mediation/caseuploadcheck/index.css" />
    <style>
        .modal.in .modal-dialog{
            transform: translate(0,50%)!important;
        }
    </style>
{/block}
{block name="page_section"}
  <div class="sessionPage">
      <ul class="nav nav-tabs" style="width: 95%; margin:10px auto;">
          <li {if $status == 1} class="active"{/if}><a href="/mediateaudit/index?status=1" style="color:#1D2129;font-size: 15px"><b>待审核</b></a></li>
          <li {if $status == 2} class="active"{/if}><a href="/mediateaudit/index?status=2" style="color:#1D2129;font-size: 15px"><b>已结案</b></a></li>
      </ul>
      <form class="small-style" method="get" action="" role="validform" enctype="multipart/form-data">
        <div class="form_row">
          <input type="hidden" name="is_show" class="showmoreishow" value="{if $is_show == 1}1{else}0{/if}">
          <input type="hidden" name="limit" value="{if $query.limit}{$query.limit}{/if}">
            <input type="hidden" name="status" value="{$status}">
            <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">调解部门:</label>
              <div class="col-sm-7">
                  <select class="form-control selectpicker"    title="请选择" name="mediationOrganId" id="mediationOrganId">
                      {foreach from=$mediationOrgan  item=info}
                          <option class="u144_input_option" {if !empty($query.mediationOrganId) &&  $info.id== $query.mediationOrganId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                      {/foreach}
                  </select>
              </div>
          </div>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">资产方:</label>
              <div class="col-sm-7">
                  <select class="form-control selectpicker"   title="请选择" name="assetsId" id="assetsId">
                      {foreach from=$assets  item=info}
                          <option class="u144_input_option" {if !empty($query.assetsId) &&  $info.id == $query.assetsId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                      {/foreach}
                  </select>
              </div>
          </div>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">调解状态:</label>
              <div class="col-sm-7">
                  <select class="form-control selectpicker"   title="请选择" name="mediateResult" id="mediateResult">
                      {foreach from=$mediateResult key=key  item=info}
                          <option class="u144_input_option" {if !empty($query.mediateResult) &&  $key == $query.mediateResult}selected="selected"{/if} value="{$key}">{$info}</option>
                      {/foreach}
                  </select>
              </div>
          </div>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">还款状态:</label>
              <div class="col-sm-7">
                  <select class="form-control selectpicker"   title="请选择" name="repayStatus" id="repayStatus">
                      {foreach from=$repayStatus  key=key item=info}
                          <option class="u144_input_option" {if !empty($query.repayStatus) &&  $key == $query.repayStatus}selected="selected"{/if} value="{$key}">{$info}</option>
                      {/foreach}
                  </select>
              </div>
          </div>
        </div>
        <div class="form_row">
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">结案理由:</label>
              <div class="col-sm-7">
                  <select class="form-control selectpicker"   title="请选择" name="closeReason" id="closeReason">
                      {foreach from=$closeReason  key=key item=info}
                      <option class="u144_input_option" {if !empty($query.closeReason) &&  $key == $query.closeReason}selected="selected"{/if} value="{$key}">{$info}</option>
                      {/foreach}
                  </select>
              </div>
          </div>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">调解员:</label>
              <div class="col-sm-7">
                  <select class="form-control selectpicker"   title="请选择" name="mediatorId" id="mediatorId">
                      {foreach from=$assets  item=info}
                          <option class="u144_input_option" {if !empty($query.mediatorId) &&  $info.id == $query.mediatorId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                      {/foreach}
                  </select>
              </div>
          </div>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">导入批次ID:</label>
              <div class="col-sm-7">
                  <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.importRecordId)}{$query.importRecordId}{/if}" name="importRecordId" id="importRecordId" placeholder="请输入~">
              </div>
          </div>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">案件标识号:</label>
              <div class="col-sm-7">
                  <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.batshId)}{$query.batshId}{/if}" name="batshId" id="batshId" placeholder="请输入~">
              </div>
          </div>
        </div>
        <div class="form_row start-hide col-lg-12" data-isshow="{if $is_show == 1}true{else}false{/if}" {if $is_show == 1}style="padding:0px;"{else}style="padding:0px;display:none;"{/if}>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">当事人:</label>
              <div class="col-sm-7">
                  <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.litigantName)}{$query.litigantName}{/if}" name="litigantName" id="litigantName" placeholder="请输入~">
              </div>
          </div>
          <div class="form-group col-lg-3 ui-select">
              <label class="col-sm-4 control-label">
                  入库时间:
              </label>
              <div class="col-sm-7">
               <input data-ele="date" data-type="daterange" name="add_begin_end" class="form-control" placeholder="请选择" value="{if !empty($smarty.get.add_begin_end)}{$smarty.get.add_begin_end}{/if}" autocomplete="off"/>
              </div>
          </div>
          <div class="form-group col-lg-3 ui-select">
              <div class="col-lg-5">
                  <button class="btn btn-primary col-lg-8 shousuoBtn"><span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
              </div>
              <div class="col-lg-5">
                  <a type="button" href="/mediateaudit/index" class="btn btn-default col-lg-8"><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
              </div>
               <div class="col-lg-5">
                  <a type="button" href="javascript:;" class="btn btn-default col-lg-8 show-more-btn">》更多</a>
              </div>
          </div>
          <div class="ui-select"></div>
        </div>
        <div class="form_row start-show" data-isshow="{if $is_show == 1}false{else}true{/if}" {if $is_show == 1}style="padding:0px;display:none;"{else}style="padding:0px;"{/if}>
          <div class="form-group col-lg-3 ui-select">
              <div class="col-lg-5">
                  <button class="btn btn-primary col-lg-8 shousuoBtn"><span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
              </div>
              <div class="col-lg-5">
                  <a type="button" href="/mediateaudit/index" class="btn btn-default col-lg-8"><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
              </div>
               <div class="col-lg-5">
                  <a type="button" href="javascript:;" class="btn btn-default col-lg-8 show-more-btn">》更多</a>
              </div>
          </div>
          <div class="ui-select"></div>
          <div class="ui-select"></div>
          <div class="ui-select"></div>
        </div>
      </form>
      <div style="width: 95%;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      overflow-x: scroll;">
        <table class="table table-striped table-bordered table-hover text-nowrap" id="tab">
          <input type="hidden" id="caseId" value="" name="caseId">
          <thead>
          <tr>
              <th><input type="checkbox" class="checkall" style="vertical-align: text-bottom"></th>
              <th>案件ID</th>
              <th>调解部门</th>
              <th>资产方</th>
              <th>调解号</th>
              <th>当事人</th>
              <th>通知</th>
              <th>借款平台</th>
              <th>借款期数</th>
              <th>结案理由</th>
              <th>欠款总额</th>
              <th>诉求金额</th>
              <th>逾期时间</th>
              <th>入库时间</th>
              <th class="fix-ele">操作</th>

          </thead>
          <tbody>
          {foreach from=$arrList item=item name=foo}
              <tr>
                  <td> <input name="checkItem" class="j-check" type="checkbox" value="{$item.id}"></td>
                  <td>{$item.id}</td>
                  <td>{$mediationOrgan[$item.mediationOrganId]['name']}</td>
                  <td>{$assets[$item.assetsId]['name']} </td>
                  <td>{$item.mediationNum}</td>
                  <td>{$item.litigantName}</td>
                  <td data-td="td">
                      <div style="display: flex;">
                          <span style="position: relative;">
                              <i data-hover="sms"  class="glyphicon glyphicon-envelope" style="cursor: pointer;color:#559DF8;margin-left:10px;font-size:16px;"></i>
                              <ul data-caseId="{$item.id}" class="dropdown-menu sms-dropdown"></ul>
                          </span>
                      </div>
                  </td>
                  <td>{$item.loanPlatform}</td>
                  <td>{$item.loanTerm}</td>
                  <td>{if empty($closeReason[$item.closeReason])}--{else}{$closeReason[$item.closeReason]}{/if}</td>
                  <td>{$item.debtTotal}</td>
                  <td>{$item.claimAmount}</td>
                  <td>{$item.overdueDate|date_format:"%Y-%m-%d %H:%M:%S"}</td>
                  <td>{$item['addTime']|date_format:"%Y-%m-%d %H:%M:%S"}</td>
                  <td class="text-nowrap fix-ele">
                      <a href="/caseinfo/caseinfo?caseId={$item.id}">详情</a >
                  </td>
              </tr>
          {/foreach}
          </tbody>
      </table>
      </div>
      <div class="mr-b20 col-lg-12 pad-no" style="float:none;">
          <input type="button" value="审核通过" data-toggle="modal" data-target="#modal_auditMeidate" class="btn btn-primary casesubmit" case_status="pass">
          <input type="button" value="审核驳回" data-toggle="modal" data-target="#modal_auditMeidate" class="btn btn-primary casesubmit" case_status="reject">
          <input type="button" value="发送通知" data-toggle="modal" data-target="#sms_modal" class="btn btn-primary sendsms">

      </div>
      <div class="clearfix pad-no text-nowrap" style="margin-top: 20px;">
          {include file="base/pagenav.html"  action="/mediateaudit/index?status={$status}" pagenum=$curPageNum inline}
          <select class="form-control" id="paglimit" style="float:right;margin:0 10px;width: auto;margin-top: -5px;">
              <option value="limit=10" {if $query.limit==10}selected="selected"{/if}>10条/页</option>
              <option value="limit=20" {if $query.limit==20}selected="selected"{/if}>20条/页</option>
              <option value="limit=50" {if $query.limit==50}selected="selected"{/if}>50条/页</option>
              <option value="limit=100" {if $query.limit==100}selected="selected"{/if}>100条/页</option>
              <option value="limit=500" {if $query.limit==500}selected="selected"{/if}>500条/页</option>
              <option value="limit=1000" {if $query.limit==1000}selected="selected"{/if}>1000条/页</option>
          </select>
          <span style="float:right;">共 {$totalnum} 条</span>
       </div>

    <div class="modal fade" id="modal_auditMeidate" tabindex="-1" role="dialog" aria-labelledby="refusal_modal" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">案件审核</h4>
                </div>
                <div class="modal-body">
                    <form id="withdraw_form">
                        <p> 即将 <span style="color: green" id="chean_num"></span> 件案件调解审核 <span style="color: red" id="audit_status"></span> ,请确认是否继续!<p >
                        <input type="hidden" value="" id="mediate_audit_status" name="mediate_audit_status">
                    </form>
                </div>
                <div class="modal-footer" style="text-align: center;">
                    <button type="button" class="btn btn-default" id="fpclosebtn" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary distribution">确定</button>
                </div>


            </div>
        </div>
    </div>
    <div class="modal fade" id="sms_modal" tabindex="-1" role="dialog" aria-labelledby="sms_modal" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">短信发送</h4>
                </div>
                <div class="modal-body" style="display: flex;">
                    <form id="entrustExpireTime_form">
                        <div class="form-group col-lg-10 ui-select">
                            <label for="exampleInputName2"  class="col-sm-3 control-label">短信模板:</label>
                            <div class="col-sm-8">
                                <select class="form-control" id="sms">
                                    <option value="" >——请选择——</option>
                                    {foreach from=$sms item=info}
                                        <option class="u144_input_option"  smscontent="{$info.content}" value="{$info.code}">{$info.name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <input type="hidden" value="1" id="batch">
                        <div id="smscontentdiv" class="form-group col-lg-10 ui-select" >
                            <label for="exampleInputName2"  class="col-sm-3 control-label">内容:</label>
                            <div class="col-sm-8">
                                <textarea id="smscontent" disabled="disabled" class="form-control" cols="50" rows="7"></textarea>
                            </div>
                        </div>

                        </br>

                    </form>

                </div>

                <div class="modal-footer" style="text-align: center;">
                    <button type="button" class="btn btn-default" id="fpclosebtn" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary determine">确定</button>
                </div>


            </div>
        </div>
    </div>


{/block}
{block name="page_scripts"}
<script type="text/template" id="smsTpl">
{foreach from=$sms item=sms1}
    <li code = "{$sms1.code}" data-fn="only-sms" val="{$sms1.content}"><a>{$sms1.name}</a></li>
{/foreach}
</script>
<script type="text/javascript" src="/js/mediation/mediateaudit/index.min.js" init="mediation/mediateaudit/index"></script>
<script type="text/javascript" src="/js/module/date.js"></script>
<script type="text/javascript">
     $(".casesubmit").on("click",function(){
        var arrbtn = [];
        $(".j-check:checked").each(function (index, ele) {
            //遍历所有复选框，然后取值进行 !非操作
            if ($(this).prop("checked")) {
                arrbtn.push($(this).val());
            }
        })
        if(arrbtn.length==0){
            toastr.error('请选择案件');
            return false;
        }
        $("#mediate_audit_status").val($(this).attr('case_status'));

        $("#chean_num").text(arrbtn.length);
        if($(this).attr('case_status') == 'pass'){
          $("#audit_status").text("通过");
        }else{
          $("#audit_status").text("驳回");
        }

    });
 function GetQueryString(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}
$('body')

.on('change','#paglimit', function(){
    console.log()
    var mediationOrganId = GetQueryString('mediationOrganId');
    var paglimit = GetQueryString('limit');
    var status = GetQueryString('status');
    var val =  $(this).val();

    if(!mediationOrganId){
        if(!paglimit && status!=null){
            window.location = window.location.href+'&'+val;
        }else if(!paglimit){
            window.location = window.location.href+'?'+val;
        }else{
            window.location = window.location.href.replace('limit='+paglimit,val);
        }
    }else{
        if(!paglimit){
            window.location = window.location.href+'&'+val;
        } else{
            window.location = window.location.href.replace('limit='+paglimit,val);
        }
    }
})


</script>
{/block}
